﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentData;
using Framework.Data;

namespace Framework.Core
{
    internal class UserRoleDataAccess:BaseDataAccess
    {
        internal List<UserRole> GetUserRoles(string userName,string orgID)
        {
            var sql = "SELECT [sUserName], [sRoleID], [sOrgID] FROM [User_Role] WHERE [sUserName]=@userName";

            using (var context = DataHelper.GetBaseDbContext())
            {
                var userRoles =
                    context.Sql(sql).Parameter("userName", userName).Parameter("OrgID", orgID).QueryMany<UserRole>(delegate(UserRole map, IDataReader reader)
                    {
                        map.OrgID = reader.GetString("sOrgID");
                        map.UserName = reader.GetString("sUserName");
                        map.RoleID = reader.GetString("sRoleID");                       
                    });
                return userRoles;
            }
        }
    }
}
